package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.ContentService;
import com.zr.service.impl.ContentServiceImpl;

import net.sf.json.JSONObject;

public class ShowContentByCnameAction extends HttpServlet{

	ContentService cs = new ContentServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setCharacterEncoding("utf8");
		req.setCharacterEncoding("utf8");
		String title = (String)req.getSession().getAttribute("cname");
		int page = Integer.parseInt(req.getParameter("page"));
		int pageSize = Integer.parseInt(req.getParameter("rows"));
		JSONObject json = cs.getContentByCname(title,page,pageSize);
		PrintWriter pw = resp.getWriter();
		pw.write(json.toString());
	}
	
}
